<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>订单销售报表</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<style>
.attr{
	margin-left:30px;
}
.editbtn{
	background-color:#339900;
	color:#FFFFFF;
	padding:2px 4px;
	cursor:pointer;
}
.entitle{
	font-size:16px;
	font-weight:bold;
}
.attr_list{
	background-color:green;
	margin-right:5px;
	color:#FFFFFF;
}
.module_form thead .thead td{
	font-weight:bold;
	background-color:#999;
	color:#FFF;
}
.total{
	margin:5px;
	background-color:#09C;
	color:#FFFFFF;
	padding:3px 5px;
	border-radius:3px;
	display:inline-block;
	text-align:center;
}
.result_form {
	width:100%;
	background-color:#FFF;
	text-align:center;
}
.result_form dt {
	font-weight:bold;
}
.result_form .count {
	background-color:#666;
	color:#FFF;
}
.result_form .part_1 {
	background-color:#EC4E35;
	color:#FFF;
}
.result_form .part_2 {
	background-color:#F90;
	color:#FFF;
}
.result_form .part_3 {
	background-color:#10AF5D;
	color:#FFF;
}
.result_form .part_4 {
	background-color:#76A503;
	color:#FFF;
}
.result_form .part_5 {
	background-color:#6C9;
	color:#FFF;
}
.result_form .part_6 {
	background-color:#0774B9;
	color:#FFF;
}
.result_form .part_7 {
	background-color:#939;
	color:#FFF;
}
.result_form .part_8 {
	background-color:#F09;
	color:#FFF;
}
#showResult {
	text-align:center;
	cursor:pointer;
}
#showMore {
	margin:auto;
	background-color:#76A503;
	color:#FFF;
	padding:3px;
	text-align:center;
	cursor:pointer;
}
.footerHeight{
	height:120px;
}
</style>
</head>

<body>
	<div class="page_wraper">
		<input type="hidden" id="solevar" name="solevar" value="{:create_id()}">
		<div id="tab1_0" fortab="tab1">
		
		<form id="search_Form" method="post" action="{:U('Order/sell')}">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				 <tr>
				 <php>if(C('ADMIN_ROLE')==session(C('USER_AUTH_ROLE'))){</php>
				    <td class="">
					  <select name="cityid" id="cityid" class="form_ele_text width_150">
						<option value="">请选择城市</option>
						<volist name="address" id="v">
							<eq name="v[2]" value="2"> 
								<option value="{$key}">{$v[0]}</option>
							</eq>
						</volist>
					  </select>
					</td> 
				<php>}</php>
					<td class="">
					  <select name="dealid" id="dealid" class="form_ele_text width_150">
							<option value="">请选择配送员</option>
					  	<volist name="user" id="v">
							<option value="{$v.id}">{$v.realname}</option>
						</volist>
					  </select>
					</td>
					<td class="">
						<input type="text" name="startTime" id="startTime" class="form_ele_text" placeholder="请选择开始时间"
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{$m.startTime}">
						-
						<input type="text" name="endTime" id="endTime" class="form_ele_text" placeholder="请选择结束时间" 
							onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{$m.endTime}">
					</td>
					<td>
						<input type="button" class="form_ele_submit searchbtn" value="确定">
						<input type="button" class="form_ele_reset restbtn" value="重置">
					</td>
					<td>
						<input type="button" class="form_ele_submit daochubtn" value="导出Excel">
					</td>
					<!-- <span>搜索方式有两种：1根据年月日搜索、2根据开始时间和结束时间搜索</span> -->
				</tr>
			</table>
		</form>
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<thead>
					<tr class="thead">
						<td>序号</td>
						<td>日期</td>
						<td>餐厅</td>
						<td>客户地址</td>
						<td>订单金额</td>
						<td>酒水饮料</td>
						<td>服务费</td>
						<td>总金额</td>
						<td>结算金额</td>
						<td>实收金额</td>
						<td>接单时间</td>
						<td>收单时间</td>
						<td>取餐时间</td>
						<td>送达时间</td>
						<td>客服用时</td>
						<td>餐厅用时</td>
						<td>快递用时</td>
						<td>实际用时</td>
						<td>快递员</td>
						<td>备注</td>
					</tr>
				</thead>
				<tbody id="orderlist">	
					<volist name="list" id="v" empty="$empty">
						<tr>
							<td>{$key+1}</td>
							<td>{$v.addtime|date='ymd',###}</td>
							<td>{$v.outletName}</td>
							<td>{$v.address}</td>
							<td>{$v.dishesfee|ceil=###}</td>
							<td>{$v.drinkfee|ceil=###}</td>
							<td>{$v['orderfee']-$v['drinkfee']-$v['dishesfee']|ceil=###}</td>
							<td>{$v.orderfee|ceil=###}</td>
							<td>{$v.settlefee|ceil=###}</td>
							<td>{$v.receivefee|ceil=###}</td>
							<td>{$v.ordertime|date='H:i',###}</td>
							<td>{$v.time_que|date='H:i',###}</td>
							<td>{$v.time_pei|date='H:i',###}</td>
							<td>{$v.time_shou|date='H:i',###}</td>
							<td>{$v['time_que']-$v['ordertime']|getminus=###}</td>
							<td>{$v['time_pei']-$v['time_que']|getminus=###}</td>
							<td>{$v['time_shou']-$v['time_pei']|getminus=###}</td>
							<td>{$v['time_shou']-$v['ordertime']|getminus=###}</td>
							<td><volist name="user" id="vo"><eq name="v.dealid" value="$vo.id">{$vo.realname}</eq></volist></td>
							<td>{$v.content}</td>
						</tr>
					</volist>
					<notempty name="param">
						<tr id="showMore" class="even" param="{$param}">
							<td colspan="20">......查看更多......</td>
						</tr>
					</notempty>
				</tbody>	
			</table>
			<div class="footerHeight"></div>
		</div>
	</div>
	<div class="page_footer" style="text-align:left">
<div id="showResult" class="up">▼</div>
<table cellpadding="0" cellspacing="0" class="result_form">
	<tr>
		<td colspan="6" class="count">
			<dl>
				<dt>订单总金额</dt>
				<dd>￥{$total.to_totalfee}</dd>
			</dl>
		</td>
	</tr>
	<tr>
		<td class="part_1">
			<dl>
				<dt>总菜品金额</dt>
				<dd>￥{$total.to_dishesfee}</dd>
			</dl>
		</td>
		<td class="part_2">
			<dl>
				<dt>总服务费</dt>
				<dd>￥{$total.to_shipfee}</dd>
			</dl>
		</td>
		<td class="part_3">
			<dl>
				<dt>总酒水金额</dt>
				<dd>￥{$total.to_drinkfee}</dd>
			</dl>
		</td>
		<td class="part_4">
			<dl>
				<dt>支付总金额</dt>
				<dd>￥{$total.to_orderfee}</dd>
			</dl>
		</td>
		<td class="part_5">
			<dl>
				<dt>结算总金额</dt>
				<dd>￥{$total.to_settlefee}</dd>
			</dl>
		</td>
		<td class="part_6">
			<dl>
				<dt>实收总金额</dt>
				<dd>￥{$total.to_receivefee}</dd>
			</dl>
		</td>
	</tr>
</table>
	</div>
</body>
<script type="text/javascript">
	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;
	$(function(){
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		
		//显示更多
		$('#showMore').live("click",function(){
			var pam = $(this).attr("param");
			if(pam){
				var url = "{:U('Order/sell')}&"+pam;
				ajaxOrder(url);
			}
		});
		
		//表格隔行换色
		$('.module_form tr:odd').addClass('odd');
		$('.module_form tr:even').addClass('even');
		
		//导出订单
		$('.daochubtn').on('click',function(){
			var action = "{:U('Order/export_sell')}";
			
			$("#search_Form").attr("action",action);
			$("#search_Form").submit();
		})
		
		//提交
		$('.searchbtn').on('click',function(){
			$("#search_Form").submit();
		});
		
		//重置
		$('.restbtn').on('click',function(){
			$('#cityid').val("");
			$('#dealid').val("");
			$('#startTime').val("");
			$('#endTime').val("");
		});
		
		$(".editAttr").click(function(){
			var id  = $(this).attr("id");
			var css = $(this).attr("css");
			
			if(css=="isshow"){
				$("#tr_"+id).show();
				$(this).attr("css","ishide");
				$(this).children("span").text("隐藏属性");
			}else{
				$("#tr_"+id).hide();
				$(this).attr("css","isshow");
				$(this).children("span").text("显示属性");
			}
		});
		
		//城市改变时重新获取配送员
		$('#cityid').on('change',function(){
			var html = '';
			html += '<option value="">请选择配送员</option>';
			$.get('__URL__/getDelivery',{cityid:$(this).val()},function(data){
				$.each(data,function(i,n){
					html += '<option value="'+n.id+'">'+n.realname+'</option>';
				});
				
				$('#delivery').html(html);
			});
		});
		
		//显示/隐藏结果集
		$("#showMore").removeClass("odd even");
		$('#showResult').on('click',function(){
			if($(this).is('.up')){
				$(this).removeClass('up').addClass('down');
				$(this).html('▼');
				$('.result_form').show();
			}else{
				$(this).addClass('up').removeClass('down');
				$(this).html('▲');
				$('.result_form').hide();
			}
		});
	});
	
	function ajaxOrder(url){
		$.ajax({
			url: url,
			dataType: "html",
			type: "get",
			cache: false,
			async:false,
			success: function(html){
				$('#showMore').remove();
				$("#orderlist").append(html);
				$('.module_form tr:odd').addClass('odd');
				$('.module_form tr:even').addClass('even');
				$("#showMore").removeClass("odd even");
				return false;
			}
		});
	}
</script>
</html>
